﻿@using CoreData
@model List<Album>
@{
    ViewBag.Title = "Album ảnh";
    Layout = "~/Views/Shared/_Layout.cshtml";
    
}
@section HeadResource{
    <title>@ViewBag.Title</title>
    <link rel="stylesheet" type="text/css" href="@Url.Content("~/Content/css/album.css")" />
}
@section BottomResource{
    <script type="text/javascript" src="@Url.Content("~/Content/js/album.js")"></script>
}
@helper PagerHelper()
    {
        {
            int totalPage = ViewBag.TotalPage;
            int currentPage = (int)ViewBag.page;
            int i = 0;
            
    <ul>
        <li class="bullet-first"><a href="@Url.Action("Index", "Album", new { page = 1 })"><<</a></li>
        @if (currentPage > 1)
        {
            <li class="bullet-prev"><a href="@Url.Action("Index", "Album", new { page = currentPage - 1 })">
                <</a></li>
        }
        @if (totalPage > 0)
        {
            var startPage = currentPage - 2;
            var endPage = currentPage + 2;
            if (startPage < 1) { startPage = 1; }
            if (endPage > totalPage) { endPage = totalPage; }

            if (currentPage >= 4)
            {
            <li>...</li>
            }
            for (i = startPage; i <= endPage; i++)
            {
                if (currentPage == i)
                {
            <li class="current-page"><a href="@Url.Action("Index", "Album", new { page = i })">@i</a></li>
                }
                else
                {
            <li><a href="@Url.Action("Index", "Album", new { page = i })">@i</a></li>
                }
            }
            if (currentPage <= totalPage - 2)
            {
            <li>...</li>
            }
        }
        @if (currentPage < totalPage)
        {
            <li class="bullet-next"><a href="@Url.Action("Index", "Album", new { page = currentPage + 1 })">
                ></a></li>
        }
        <li class="bullet-last"><a href="@Url.Action("Index", "Album", new { page = totalPage })">
            >></a></li>
    </ul>
        }
}
@section MainBanner{
    <div id="sliderMain">
        <div class="slide-item">
            <div class="slide-content">
                <h4 class="slide-title">
                    <span>@ViewBag.Title</span>
                </h4>
            </div>
            @if (Model != null && Model.Count() > 0)
            {
                var randomImg = Model.OrderBy(x => Guid.NewGuid()).ToList().First();
                <img src="/Media/Album/@randomImg.Image" alt="" />
            }
        </div>
    </div>
}
<div class="main-content child-page">
    <div class="col-small">
        <div class="module">
            @Html.Action("_ListNewsOnColSmall2", "Article")
        </div>
        @*<div class="module">
            @Html.Action("_ListNewsOnColSmall", "Article", new { catid = 1 })
        </div>*@
    </div>
    <div class="col-content">
        <div class="module album">
            <div id="breadcrumbs">
                <ul>
                    <li><a href="@Url.Action("Index", "Home")">Trang chủ</a><span class="raquo">»</span></li>
                    <li><span>@ViewBag.Title</span><span class="raquo">»</span></li>
                </ul>
            </div>
            <ul class="main-list-album">
                @if (Model != null && Model.Count != 0)
                {
                    foreach (var item in Model)
                    {
                    <li class="album-item">
                        <div class="inner-item">
                            <a href="@Url.Action("Detail", "Album", new { id = item.ID })">
                                <img src="/Media/Album/@item.Image" alt="@item.Image" />
                            </a>
                            <div class="album-description">
                                <p>
                                    @item.Name</p>
                            </div>
                        </div>
                    </li>
                    }
                }
            </ul>
            <div class="clearfix">
            </div>
        </div>
        <div class="module">
            <div class="module-foot pager">
                @PagerHelper()
            </div>
        </div>
    </div>
    <div class="clearfix">
    </div>
</div>
